package com.xy.biz.mes.domain.converter;

import java.util.Collection;
import java.util.List;

import com.xy.biz.mes.domain.bo.ManufactureResultBO;
import com.xy.biz.mes.domain.query.ManufactureResultQuery;
import com.xy.tool.util.BeanUtilsEx;
import com.xy.biz.mes.domain.po.ManufactureResultPO;
import com.xy.biz.mes.domain.resp.GetManufactureResultResponse;
import com.xy.biz.mes.domain.req.SaveManufactureResultRequest;
import com.xy.biz.mes.domain.req.ListManufactureResultRequest;

/**
 *
 *
 * @author zgy
 * @date 2022-2-11
 */
public class ManufactureResultConverter {

    public static ManufactureResultPO toPO(ManufactureResultBO source) {
        return BeanUtilsEx.copyProperties(source, () -> new ManufactureResultPO(), true);
    }

    public static List<ManufactureResultPO> toPO(Collection<ManufactureResultBO> source) {
        return BeanUtilsEx.copyPropertiesForNewList(source, () -> new ManufactureResultPO(), true);
    }

    public static ManufactureResultBO fromPO(ManufactureResultPO source) {
        return BeanUtilsEx.copyProperties(source, () -> new ManufactureResultBO());
    }

    public static List<ManufactureResultBO> fromPO(Collection<ManufactureResultPO> source) {
        return BeanUtilsEx.copyPropertiesForNewList(source, () -> new ManufactureResultBO());
    }

    public static ManufactureResultBO toBO(SaveManufactureResultRequest source) {
        return BeanUtilsEx.copyProperties(source, () -> new ManufactureResultBO());
    }

    public static List<ManufactureResultBO> toBO(Collection<SaveManufactureResultRequest> source) {
        return BeanUtilsEx.copyPropertiesForNewList(source, () -> new ManufactureResultBO(), true);
    }

    public static GetManufactureResultResponse toResponse(ManufactureResultBO source) {
        return BeanUtilsEx.copyProperties(source, () -> new GetManufactureResultResponse());
    }

    public static List<GetManufactureResultResponse> toResponse(Collection<ManufactureResultBO> source) {
        return BeanUtilsEx.copyPropertiesForNewList(source, () -> new GetManufactureResultResponse(), (s, t) -> {
            t.setManufactureResultGoodsList(ManufactureResultGoodsConverter.toResponse(s.getManufactureResultGoodsList()));
        });
    }

    public static ManufactureResultQuery toQuery(ListManufactureResultRequest source) {
        if (null == source) {
            return null;
        }
        ManufactureResultQuery target = new ManufactureResultQuery(source.getPageIndex(), source.getPageSize());
        BeanUtilsEx.copyProperties(source, target);
        return target;
    }

}
